package org.pentaho.di.ui.trans.steps.missing.listener;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Shell;
import org.pentaho.di.ui.spoon.Spoon;

/**
 * @author yzbdl@yzbdl.ac.cn
 * @version: 1.0
 * @Date 2021/2/22 10:12
 **/
public class ClientListener implements PaintListener {
    private static Color sysBlack =(Spoon.getInstance()==null?null: new Color(Spoon.getInstance().getDisplay(), 22, 155, 233));
    private Shell shellParent;
    private String clientName;


    public ClientListener(Shell shellParent,String clientName) {
        this.shellParent = shellParent;
        this.clientName = clientName;
    }

    @Override
    public void paintControl(PaintEvent paintEvent) {
        final int width = paintEvent.width;
        final int height = paintEvent.height;
        GC gc = paintEvent.gc;
        gc.setBackground(sysBlack);
        gc.fillRoundRectangle(5, 5, 60, 20, 15, 15);
        Font font = new Font(shellParent.getDisplay(), "Arial", 14, SWT.BOLD | SWT.ITALIC);
        gc.setForeground(shellParent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
        gc.drawText(clientName, 13, 6);
        gc.setFont(font);
    }
}
